/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    code: { type: String, _type: 'code', title: '编码', required: true },
    date: { type: Date, _type: 'date', title: '日期', required: true, enableArea: [ 'table', ] },
    customer: { type: String, _type: 'string', title: '客户名称',required: true,  enableArea: [ 'table', ], },
    salesman: { type: String, _type: 'string', title: '业务员', enableArea: [ 'table', ], },
    company: { type: String, _type: 'string', title: '公司行业', enableArea: [ 'table', ], },
    process: { type: String, _type: 'string', title: '现场工艺流程', enableArea: [], },
    application: {
      type: String,
      _type: 'select',
      title: '药剂应用场景',
      options: [ '气浮', '沉降', '脱泥' ],
      enableArea: [ 'table', ],
    },
    device: { type: String, _type: 'string', title: '应用设备', enableArea: [ 'table', ], },
    waterCount: { type: String, _type: 'string', title: '现场水量', enableArea: [ 'table', ], },
    emissionStandard: { type: String, _type: 'string', title: '现场排放标准', enableArea: [ 'table', ], },
    ph: { type: String, _type: 'string', title: '原水PH值', enableArea: [ 'table', ], },
    hasWaterSample: {
      type: String, _type: 'select', title: '有无水样', options: [ '有', '无' ], enableArea: [
        'table',  'search'
      ],
    },
    waterSampleOrigin: {
      type: String, _type: 'string', title: '水样来源', enableArea: [],
    },
    hasMedicineSample: {
      type: String, _type: 'select', title: '有无药样', options: [ '有', '无' ], enableArea: [
        'table',  'search'
      ],
    },
    medicineSampleOrigin: {
      type: String, _type: 'string', title: '药样来源', enableArea: [],
    },
    customerSampleBoard: {
      type: String, _type: 'string', title: '客样品牌', enableArea: []
    },
    MedicineSampleName: {
      type: String, _type: 'string', title: '药样名称', enableArea: []
    },
    require: {
      type: String, _type: 'string', title: '实验要求', enableArea: []
    },
    customerSampleConductance: {
      type: String, _type: 'string', title: '客样电导', enableArea: []
    },
    customerSampleViscosity: {
      type: String, _type: 'string', title: '客样粘度', enableArea: []
    },
    sludgeRate: {
      type: String, _type: 'number', title: '污泥量/ml', enableArea: []
    },
    aMedicine: {
      type: String, _type: 'string', title: 'A药剂', enableArea: []
    },
    aRate: {
      type: String, _type: 'number', title: '溶解比例%', enableArea: []
    },
    aAdd: {
      type: String, _type: 'number', title: '投加量/ml', enableArea: []
    },
    bMedicine: {
      type: String, _type: 'string', title: 'B药剂', enableArea: []
    },
    bRate: {
      type: String, _type: 'number', title: '溶解比例%', enableArea: []
    },
    bAdd: {
      type: String, _type: 'number', title: '投加量/ml', enableArea: []
    },
    cMedicine: {
      type: String, _type: 'string', title: 'C药剂', enableArea: []
    },
    cRate: {
      type: String, _type: 'number', title: '溶解比例%', enableArea: []
    },
    cAdd: {
      type: String, _type: 'number', title: '投加量/ml', enableArea: []
    },
    dMedicine: {
      type: String, _type: 'string', title: 'D药剂', enableArea: []
    },
    dRate: {
      type: String, _type: 'number', title: '溶解比例%', enableArea: []
    },
    dAdd: {
      type: String, _type: 'number', title: '投加量/ml', enableArea: []
    },

    result: { type: String, _type: 'string', title: '结果描述', },
    memo: { type: String, _type: 'string', title: '备注', },

  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DicExperiment', _schema);
};
